<?php foreach($dialogs as $dialog){ ?>
	<?php $class = ($dialog['from'] == Yii::app()->user->id) ? 1 : $dialog['read']; ?>
	<div class="f_dialog_item status<?php echo $class;?>">
		<div class="f_dialog_item_l">
			<div class="u_buzz_item_l">
				<a href="<?php echo Yii::app()->createUrl('profile/index', array('id'=>$dialog['user_id']));?>">
					<?php echo $this->material_image('', $dialog['avatar'], '50', 'photos/'. $dialog['user_id'] . '/' . 0); ?>
				</a>
			</div>
			<div class="u_buzz_item_r">
				<div class="u_buzz_name">
					<a href="<?php echo Yii::app()->createUrl('profile/index', array('id'=>$dialog['user_id']));?>"><?php echo CHtml::encode($dialog['full_name']); ?></a>
					
					<?php $date_diff = date_diff(date_create($dialog['crdate']), date_create()); ?>
					<?php if($date_diff->h){ ?>
						<p class="u_buzz_date"><?php echo Yii::app()->dateFormatter->formatDateTime($dialog['crdate'], 'long','short'); ?></p>
					<?php }else{ ?>
						<p class="u_buzz_date"><?php echo $date_diff->i; ?> мин. назад</p>
					<?php } ?>						
				</div>
			</div>
		</div>
		<div class="f_dialog_item_r ">
			<table class="f_dialog_item_text"><tr><td>
				<a href="<?php echo Yii::app()->createUrl('messages/getdialog', array('companion'=>$dialog['dialog'], 'profile'=>Yii::app()->request->getParam('profile')));?>">
					<?php echo CHtml::encode($dialog['text']); ?>
				</a>
			</td></tr></table>
			<div class="u_buzz_link_block hidden">
				<a href="<?php echo Yii::app()->createAbsoluteUrl("messages/deletedialog", array('companion'=>$dialog['dialog'])); ?>" onclick="return false;" class="u_buzz_link l2 delete_dialog">
					<div class="user_action_item_tooltip c hidden"><div class="cc">Удалить диалог</div></div>
				</a>
			</div>
		</div>
	</div>			
<?php } ?>